﻿<Window x:Class="XWord.GUI.Views.Infrastructure.OptionManagerView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:inf="http://schemas.xword.com/winfx/xaml/info"
    xmlns:local="clr-namespace:XWord.GUI.Views.Infrastructure"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
    xmlns:cal="http://www.caliburnproject.org"
    xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    SizeToContent="WidthAndHeight"
    Title="{inf:Resource Infrastructure_OptionManager_ModuleName}" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
    <Window.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Left"></Setter>
            <Setter Property="Margin" Value="2,0,5,0"></Setter>
        </Style>
        <Style TargetType="TextBox" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.TextBoxKey}}">
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
        </Style>
        <Style TargetType="TextBlock" x:Key="HeadTextBlock">
            <Setter Property="Foreground" Value="#FF475C69"></Setter>
            <Setter Property="FontWeight" Value="Bold"></Setter>
        </Style>
        <Style TargetType="HeaderedContentControl">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="HeaderedContentControl">
                        <StackPanel>
                            <TextBlock Text="{TemplateBinding Header}" Margin="0,0,0,3" Style="{StaticResource HeadTextBlock}"/>
                            <ContentPresenter Margin="20,0,0,0"/>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <TabControl Background="{DynamicResource {x:Static themes:RibbonCommonDictionary.RibbonControlLargeBackgroundSemiHoverBrushKey}}"  Height="280"  Width="450" DataContext="{Binding Config}" Grid.Row="0" TabStripPlacement="Left" BorderThickness="1">
            <TabItem Header="{inf:Resource Infrastructure_OptionManager_General}">
                <Grid Margin="10,10,20,20" Name="General_Grid" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Visibility="Visible">
                    <StackPanel>
                        <HeaderedContentControl Header="{inf:Resource Infrastructure_OptionManager_StartEndSetting}">
                            <StackPanel>
                                <CheckBox Content="{inf:Resource Infrastructure_OptionManager_AutoRun}"
                                     IsChecked="{Binding AutoRun}"/>
                                <!--<CheckBox Content="{inf:Resource Infrastructure_OptionManager_AutoLogin}"
                                     IsChecked="{Binding AutoLogin,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>-->
                            </StackPanel>
                        </HeaderedContentControl>

                        <HeaderedContentControl Header="{inf:Resource Infrastructure_OptionManager_SoftUpdate}">
                            <CheckBox Content="{inf:Resource Infrastructure_OptionManager_AutoUpdate}"
                                  IsChecked="{Binding AutoUpdate}"/>
                        </HeaderedContentControl>

                        <HeaderedContentControl Header="{inf:Resource Infrastructure_OptionManager_MainWindow}">
                            <CheckBox Content="{inf:Resource Infrastructure_OptionManager_TopProgram}"
                                  IsChecked="{Binding IsTopmost}"/>
                        </HeaderedContentControl>
                        <HeaderedContentControl Margin="20,0,0,0" Header="{inf:Resource Infrastructure_OptionManager_CloseProgram}">
                            <shared:RadioButtonList BorderThickness="0" SelectedValue="{Binding CloseWindowMode}" SelectedValuePath="Tag">
                                <ListBoxItem Tag="Mini" Content="{inf:Resource Infrastructure_OptionManager_MinProgram}"></ListBoxItem>
                                <ListBoxItem Tag="Close" Content="{inf:Resource Infrastructure_OptionManager_ExitProgram}"></ListBoxItem>
                            </shared:RadioButtonList>
                        </HeaderedContentControl>
                        <!--<HeaderedContentControl  Header="语言">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <TextBlock Text="选择当前程序语言(重启程序后有效)"/>
                            <ComboBox Width="100" SelectedValue="Language" SelectedValuePath="Tag">
                                <ComboBoxItem Tag="zh-cn" Content="简体"/>
                                <ComboBoxItem Tag="zh-tw" Content="繁體"/>
                            </ComboBox>
                            </StackPanel>
                        </HeaderedContentControl>-->
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="{inf:Resource Infrastructure_OptionManager_ProxyName}">
                <HeaderedContentControl Margin="10,10,20,20" Header="{inf:Resource Infrastructure_OptionManager_ProxySetting}">
                    <Grid Name="ProxyAndNet_Grid" DataContext="{Binding Proxy}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="120"  />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="80"  />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0" />
                            <RowDefinition Height="30" />
                            <RowDefinition Height="30"  />
                            <RowDefinition Height="30" />
                            <RowDefinition Height="30" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" Grid.Column="0" Text="{inf:Resource Infrastructure_OptionManager_ProxyType}"/>
                        <ComboBox VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Name="Combobox_ProxyType" SelectedValuePath="Tag" SelectedValue="{Binding ProxyType}">
                            <ComboBoxItem Tag="None" Content="{inf:Resource Infrastructure_OptionManager_NotUseProxy}" />
                            <ComboBoxItem Tag="Http" Content="{inf:Resource Infrastructure_OptionManager_HttpProxy}" />
                            <!--<ComboBoxItem Tag="Socket4" Content="{inf:Resource Infrastructure_OptionManager_Socket4}" />
                            <ComboBoxItem Tag="Socket5" Content="{inf:Resource Infrastructure_OptionManager_Socket5}" />-->
                        </ComboBox>
                        <TextBlock Grid.Row="2" Text="{inf:Resource Infrastructure_OptionManager_ProxyServerAddress}"/>
                        <TextBox Grid.Row="2" Grid.Column="1" Name="Text_Proxy_Ip" Text="{Binding IP,UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Grid.Row="2" Grid.Column="2" Text="{inf:Resource Infrastructure_OptionManager_ProxyPort}" />
                        <TextBox Grid.Row="2" Grid.Column="3" Name="Text_Proxy_Port" Text="{Binding Port,UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Grid.Row="3" Grid.Column="0" Text="{inf:Resource Infrastructure_OptionManager_ProxyUsername}" />
                        <TextBox Grid.Row="3" Grid.Column="1" Name="Text_Proxy_User" Text="{Binding Username,UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Grid.Row="3" Grid.Column="2" Text="{inf:Resource Infrastructure_OptionManager_ProxyPassword}" />
                        <PasswordBox VerticalAlignment="Center"  Grid.Row="3" Grid.Column="3" Name="Text_Proxy_Pwd">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="PasswordChanged">
                                    <inf:ReadOnlyPropertyAction Property="Password" Reverse="True" BindablePropertyItem="{Binding Password,Mode=TwoWay}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </PasswordBox>
                        <TextBlock Grid.Row="4" Grid.Column="0" Text="{inf:Resource Infrastructure_OptionManager_ProxyDomain}" />
                        <TextBox Grid.Row="4" Grid.Column="1" Name="Text_Proxy_Domain" Text="{Binding Domain}"/>
                        <Button cal:Message.Attach="TestProxy" HorizontalAlignment="Left" Grid.ColumnSpan="2" Grid.Row="5" Grid.Column="0" Name="TestProxyButton" Content="{inf:Resource Infrastructure_OptionManager_TextProxyDomain}" />
                    </Grid>
                </HeaderedContentControl>
            </TabItem>
            <TabItem Header="语音">
                <GroupBox Header="TTS语音合成发音">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="52*" />
                            <ColumnDefinition Width="236*" />
                        </Grid.ColumnDefinitions>
                        <Label Content="声音：" Name="label1" />
                        <Label Content="音量：" Name="label2" Grid.Row="1" />
                        <Label Content="音调：" Name="label3" Grid.Row="2" />
                        <Label Content="速度：" Grid.Row="3" Name="label4" Grid.ColumnSpan="2" Grid.RowSpan="4" />
                        <ComboBox  Grid.Column="1"  Name="comboBox1" DisplayMemberPath="VoiceInfo.Name"  SelectedValuePath="VoiceInfo.Name" SelectedValue="{Binding TTSConfig.VoiceName}"
                                  ItemsSource="{Binding DataContext.InstalledVoices,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:OptionManagerView}}}" />
                        <Slider Grid.Column="1" Grid.Row="1" Name="slider1" Minimum="0" Maximum="100" Value="{Binding TTSConfig.Volume}" />
                        <!--<Slider Name="slider2" Grid.Column="1" Grid.Row="2" />-->
                        <Slider Name="slider3" Minimum="-10" Maximum="10" Grid.Column="1" Grid.Row="3"  Value="{Binding TTSConfig.Rate}" />
                        <Label Content="输入文本测试：" Name="label5" Grid.Row="4" Grid.ColumnSpan="2" />
                        <DockPanel Grid.ColumnSpan="2" Grid.Row="5">
                            <TextBox Height="23" Name="textBox1" Width="203" />
                            <Button Content="测试" Height="23" Name="button1"
                                    cal:Message.Attach="TestSpeak(textBox1.Text)" 
                                    Width="75" DockPanel.Dock="Right" />
                        </DockPanel>
                    </Grid>
                </GroupBox>
            </TabItem>
        </TabControl>
        <DockPanel Grid.Row="1" Background="{DynamicResource {x:Static themes:RibbonCommonDictionary.KeyTipBackgroundBrushKey}}">
            <Button Margin="0,3,0,3" cal:Message.Attach="ResetDefaultOption" Content="恢復默認值"/>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,20,0">
                <StackPanel.Resources>
                    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Static ribbon:RibbonStyles.ButtonKey}}">
                        <Setter Property="Width" Value="50"/>
                        <Setter Property="Margin" Value="0,3,5,3"/>
                    </Style>
                </StackPanel.Resources>
                <Button cal:Message.Attach="SaveOptions" Content="{inf:Resource OK}"/>
                <Button cal:Message.Attach="CancelOption" Content="{inf:Resource Cancel}"/>
                <Button cal:Message.Attach="ApplyOptions" Content="{inf:Resource Apply}"/>
            </StackPanel>
        </DockPanel>
    </Grid>
</Window>
